Interactive and Chloropleth Maps: Oil Spills

Build an exploratory interactive map of California oil spill events in 2008 and create a chloroplethmap of the number of inland spill events by county.

Katelin Seeto true
03-12-2021

Attach packages

hide

Exploratory interactive map of locations of oil spill events

hide
# Create interactive map showing oil spill locations 
tmap_mode("view")

tm_shape(ca_counties) +
  tm_polygons() +
tm_shape(spill_data_sp) + 
  tm_dots()

Static cloropleth map of inland oil spill events by county for 2008

hide
# Static chloropleth map where fill color for each county depends on spill count

ca_spill_data <- ca_counties %>% 
  st_join(spill_data) %>% 
  filter(inlandmari == "Inland")

# Count number of oil spill incidents
spill_counts <- ca_spill_data %>% 
  count(name)

# Create static chloropleth map 
ggplot(data = spill_counts) +
  geom_sf(aes(fill = n), 
          color = "white") +
  scale_fill_gradientn(colors = c("navajowhite", "orange", "orangered")) + 
  theme_minimal() +
  labs(x = "Longitude",
       y = "Latitude", 
       fill = "Number of spill events")

Data citation:

California Department of Fish and Wildlife, Office of Spill Prevention and Response. 2009. Oil Spill Incident Tracking [ds394]. https://gis.data.ca.gov/datasets/CDFW::oil-spill-incident-tracking-ds394?geometry=-147.064%2C30.769%2C-91.780%2C43.020